﻿using AutoMapper;
using BBICMS.Infrastructure.Email;
using BBICMS.WebUI.Mapping;
using Glimpse.Mvc.AlternateType;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


namespace BBICMS.WebUI
{
    public static class Bootstrapper
    {
        public static void Run()
        {
            //SetAutofacContainer();
            //Configure AutoMapper
            AutoMapperConfiguration.Configure();         
        }
        //private static void SetNotFound()
        //{
        //    NotFoundConfig.OnNotFound = (req, uri) =>
        //    {
        //        // The current URI, which can be the same as the original requested URI http://localhost:43825/bin
        //        // or something triggered from the IIS via the system.webServer/httpErrors http://localhost:43825/notfound?404;http://localhost:43825/bin
        //        System.Diagnostics.Trace.WriteLine(req.Url.ToString());

        //        // This is the original requested URI http://localhost:43825/bin
        //        System.Diagnostics.Trace.WriteLine(uri);

        //        // Log.Warn(CultureInfo.InvariantCulture, "404 {0}", uri);

        //        Elmah.ErrorSignal.FromCurrentContext().Raise(new HttpException(404, uri.ToString()));
        //    };
        //}
        private static void SetAutofacContainer()
        {


         //   var builder = new ContainerBuilder();
         //   builder.RegisterControllers(Assembly.GetExecutingAssembly());
         //   builder.RegisterType<UnitOfWork>().As<IUnitOfWork>().InstancePerHttpRequest();
         //   builder.RegisterType<DatabaseFactory>().As<IDatabaseFactory>().InstancePerHttpRequest();
         //   builder.RegisterAssemblyTypes(typeof(FocusRepository).Assembly)
         //   .Where(t => t.Name.EndsWith("Repository"))
         //   .AsImplementedInterfaces().InstancePerHttpRequest();
         //   builder.RegisterAssemblyTypes(typeof(GoalService).Assembly)
         //  .Where(t => t.Name.EndsWith("Service"))
         //  .AsImplementedInterfaces().InstancePerHttpRequest();

         //   builder.RegisterAssemblyTypes(typeof(DefaultFormsAuthentication).Assembly)
         //.Where(t => t.Name.EndsWith("Authentication"))
         //.AsImplementedInterfaces().InstancePerHttpRequest();

         //   builder.Register(c => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new SocialGoalEntities())))
         //       .As<UserManager<ApplicationUser>>().InstancePerHttpRequest();

         //   builder.RegisterFilterProvider();
         //   IContainer container = builder.Build();
         //   DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }

        //public static IUnityContainer Initialise()
        //{
        //    var container = BuildUnityContainer();

        //    DependencyResolver.SetResolver(new UnityDependencyResolver(container));

        //    return container;
        //}

        //private static IUnityContainer BuildUnityContainer()
        //{
        //    var container = new UnityContainer();

        //    // register all your components with the container here
        //    // it is NOT necessary to register your controllers

        //    // e.g. container.RegisterType<ITestService, TestService>();    
        //    RegisterTypes(container);

        //    return container;
        //}

        //public static void RegisterTypes(IUnityContainer container)
        //{
        //    container.RegisterType<IEmailService, SMTPService>();
        //}
    }
}